package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.Brand;
import top.tsyz.service.IBrandService;

import java.util.List;

/**
 * BrandController控制器
 */
@RestController
@RequestMapping("/api/brands")
@Api(tags = "Brand管理接口")
public class BrandController {

    @Autowired
    private IBrandService ibrandservice;

    @GetMapping("/list")
    @ApiOperation("获取所有Brand")
    public List<Brand> list() {
        return ibrandservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取Brand")
    public Brand getById(@PathVariable Long id) {
        return ibrandservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增Brand")
    public boolean save(@RequestBody Brand brand) {
        return ibrandservice.save(brand);
    }

    @PutMapping
    @ApiOperation("更新Brand")
    public boolean update(@RequestBody Brand brand) {
        return ibrandservice.updateById(brand);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除Brand")
    public boolean delete(@PathVariable Long id) {
        return ibrandservice.removeById(id);
    }
}
